package com.zz.common.utils;

import java.io.File;

import android.os.Environment;
import android.os.StatFs;

public abstract class StorageUtil {
	public static String getSDCardDir() {
		String path = Environment.getExternalStorageDirectory().getPath();
		if(null != path && !path.endsWith("/")) {
			path = path + "/";
		}
		return path;
	}
    
	public static boolean isSDCardExist() {
		return Environment.MEDIA_MOUNTED.equalsIgnoreCase(Environment.getExternalStorageState());
	}
	
	public static long getAvailableExternalMemorySize() {    
        File path = Environment.getExternalStorageDirectory();    
        StatFs stat = new StatFs(path.getPath());    
        long blockSize = stat.getBlockSize();    
        long availableBlocks = stat.getAvailableBlocks();    
        return availableBlocks * blockSize;      
    }    
        
    public static long getTotalExternalMemorySize() {      
        File path = Environment.getExternalStorageDirectory();   
        Environment.getExternalStorageState();
        StatFs stat = new StatFs(path.getPath());
        long blockSize = stat.getBlockSize();
        long totalBlocks = stat.getBlockCount();   
        return totalBlocks * blockSize;  
    }
}
